/*
 * Form.h
 * Authors: 107 <107@mail.ru>
 * License: GPL >=2.0
 *
 */

#ifndef FORM_H_
#define FORM_H_

#include <FBase.h>
#include <FUi.h>
#include <FIo.h>
#include "Viewer.h"
#include "InheritanceContainer.h"

class MainForm :
	public Osp::Ui::Controls::Form,
	public Osp::Ui::IActionEventListener,
 	public Osp::Ui::ITextEventListener,
 	public Osp::Ui::IOrientationEventListener,
 	public Osp::Ui::ITouchEventListener,
	public badadev::InheritanceContainer,
	public ScrolledViewer
{

// Construction
public:
	MainForm(void);
	virtual ~MainForm(void);
	bool Initialize(void);
	// events
	enum {	ON_OPEN_FILE=1100,
			ON_SAVE_AS,
			ON_EDITOR_OPEN
	};


// Implementation
private:

	enum { ID_SOFTKEY_LEFT=1200,
		   ID_SOFTKEY_RIGHT ,
		   ID_OPTIONKEY,
		   ID_OPTIONKEY_SAVE_AS,
		   ID_OPTIONKEY_LICENSE,
		   ID_OPTIONKEY_NEW,
		   ID_OPTIONKEY_ABOUT
	};

	// components
	Osp::Ui::Controls::OptionMenu 	*__pOptionMenu;

	// variables
	Osp::Graphics::Point			touch;
	int		y; 						// tmp for store touch position
	bool							IsSaved;

	// functions
	void	CheckUnsaved ( void );
	// virtual
	void	msg ( const Osp::Base::String title, const Osp::Base::String message ); // show message on screen
	Osp::Graphics::Canvas *GetRealCanvasN ( void ); //

public:

	// methods
	void	Save ( void );
	void	SetSavedStatus ( bool );

	// reactions
	virtual result OnInitializing(void);
	virtual result OnTerminating(void);

	virtual result OnDraw( void );


	virtual void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
	virtual void OnOrientationChanged(const Osp::Ui::Control &source, Osp::Ui::OrientationStatus orientationStatus);

	virtual void OnTouchDoublePressed(const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchFocusIn(const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchFocusOut(const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchLongPressed(const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchMoved(const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchPressed(const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchReleased(const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);

	virtual void OnTextValueChangeCanceled(const Osp::Ui::Control &source);
	virtual void OnTextValueChanged(const Osp::Ui::Control &source);


};


#endif /* FORM_H_ */
